package edu.nf.project.mappers.accountsAndPermissions.convention;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.nf.project.entitys.dto.accountsAndPermissions.UserRoleDTO;
import edu.nf.project.entitys.entity.accountsAndPermissions.convention.Roles;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 角色 mapper 接口
 */
@Mapper
public interface RolesMapper extends BaseMapper<Roles> {
    /**
     * 获取全部用户ID与对应角色名的集合
     * @return 用户ID与角色名集合
     */
    @Select("SELECT ur.u_id, r.r_name " +
            "FROM users_roles ur " +
            "JOIN roles r ON ur.r_id = r.r_id")
    List<UserRoleDTO> selectAllUserRoles();
}
